//
//  HomelTableViewCellBottomView.swift
//  JKWeiBo
//
//  Created by 王冲 on 2017/12/19.
//  Copyright © 2017年 希爱欧科技有限公司. All rights reserved.
//

import UIKit

class HomelTableViewCellBottomView: UIView {

    //1.首先在要传值的页面 定义
    typealias ClickBlock = (_ click: Int)->()
    //2.生成
    var block: ClickBlock?
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        // 工具条的布局
        setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUI() {
        
        // 1.添加子控件
        addSubview(self.retweetBtn)
        addSubview(self.unlikeBtn)
        addSubview(self.commentBtn)
        
        unlikeBtn.x = retweetBtn.frame.maxX
        commentBtn.x = unlikeBtn.frame.maxX
        
        // 2.布局子控件
    }
    
    // 转发
    private lazy var retweetBtn: UIButton = {
        
        let button =  UIButton.creatHomeButton(imageName: "timeline_icon_retweet", tittleName: "转发")
        button.addTarget(self, action: #selector(HomelTableViewCellBottomView.commentClick(btn:)), for: UIControlEvents.touchUpInside)
        button.tag = 101
        return button
    }()
    
    // 赞
    private lazy var unlikeBtn: UIButton = {
        
        let button = UIButton.creatHomeButton(imageName: "timeline_icon_unlike", tittleName: "赞")
        button.addTarget(self, action: #selector(HomelTableViewCellBottomView.commentClick(btn:)), for: UIControlEvents.touchUpInside)
        button.tag = 102
        return button
        
    }()
    
    // 评论
    lazy var commentBtn: UIButton = {
        
        let button = UIButton.creatHomeButton(imageName: "timeline_icon_comment", tittleName: "评论")
        button.addTarget(self, action: #selector(HomelTableViewCellBottomView.commentClick(btn:)), for: UIControlEvents.touchUpInside)
        button.tag = 103
        return button
    }()
    
    // MARK: cell下面工具条的点击事件
    func commentClick(btn:UIButton) {
        
        self.block?(btn.tag)
    }

}
